﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SubSonic;
using DataAccess;

public partial class ReviseContracts : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void ButtonRevise_Click(object sender, EventArgs e)
    {
        TblContractCollection contractCollection = new TblContractCollection();
        contractCollection.LoadAndCloseReader(TblContract.FetchAll());
        var advisorContracts = new List<TblContract>();
        var surveyourContracts = new List<TblContract>();
        foreach (var contract in contractCollection)
        {
            TblTaskCollection taskCollection = new TblTaskCollection();
            if (contract.ContractType == true)
            {
                taskCollection.LoadAndCloseReader(TblTask.FetchByParameter(TblTask.Columns.ContractId , contract.Id));
                if (taskCollection.Count == 0)
                {
                    advisorContracts.Add(contract);
                }
            }
            else
            {
                taskCollection.LoadAndCloseReader(TblTask.FetchByParameter(TblTask.Columns.ContractId, contract.Id));
                if (taskCollection.Count == 0)
                {
                    surveyourContracts.Add(contract);
                }
            }
        }
    }
}